package com.mytrans.util;

import com.mytrans.beans.ReturnObject;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

public abstract class JsonType<T> {

    private final Type type;

    protected JsonType() {
        Type[] types = ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments();
        this.type = types == null || types.length > 0 ? ReturnObject.class : types[0];
    }

    /**
     * Gets underlying {@code Type} instance.
     */
    public final Type getType() {
        return type;
    }
}
